package com.yunhe.authority.repository.paymentInfo;

import com.yunhe.authority.domain.company.IncreasePercent;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @ClassName: IncreasePercentRepository
 * @Description:
 * @author: GongDaCheng
 * @Date: 17:03 2021/7/16
 */
@Repository
public interface IncreasePercentRepository extends Neo4jRepository<IncreasePercent, Long> {

    /**
     * @Description 根据企业id查询企业物业费用增幅比例
     * @Param Long companyId
     * @Return IncreasePercent
     * @Date 2021/7/16 17:04
     */
    @Query("match (c:Company)-[r:HAS_INCREASE_PERCENT]->(n:IncreasePercent) where ID(c)={companyId} return n")
    IncreasePercent getByCompanyId(@Param("companyId") Long companyId);

    /**
     * @Description 企业物业费用增幅比例与企业绑定
     * @Param Long companyId, Long id
     * @Return
     * @Date 2021/7/16 17:06
     */
    @Query("match (c:Company),(n:IncreasePercent) where ID(c)={companyId} and ID(n)={id} create (c)-[r:HAS_INCREASE_PERCENT]->(n)")
    void bindCompany(@Param("companyId") Long companyId, @Param("id") Long id);

    /**
     * @Description 根据企业id解绑并删除企业物业费用增幅比例
     * @Param Long companyId
     * @Return
     * @Date 2021/8/17 17:48
     */
    @Query("match (c:Company)-[r:HAS_INCREASE_PERCENT]->(n:IncreasePercent) where ID(c)={companyId} delete r, n")
    void unbindAndDelete(@Param("companyId") Long companyId);
}
